package com.resume.view.slidingfragment;

import java.util.HashMap;
import java.util.Map;

import com.resume.view.slidingfragment.fragment.OpusFragment;
import com.resume.view.slidingfragment.fragment.AbilityFragment;
import com.resume.view.slidingfragment.fragment.ContectFragment;
import com.resume.view.slidingfragment.fragment.ExperienceFragment;
 

import android.content.Context;
import android.support.v4.app.Fragment;
 
 /**
  * FragmentControl
  * @author Zhongdaxia 2013-12-9 17:10:28
  *
  */

@SuppressWarnings("unused")
public class FragmentControl {
	
	private static  FragmentControl instance;
	private Context mContext;
	
	private Map<String,Object> mFragmentMaps = new HashMap<String, Object>();
	
	public static final String FRAGMENT_EXPERIENCE = "FRAGMENT_EXPERIENCE";
	public static final String FRAGMENT_ABILITY = "FRAGMENT_ABILITY";
	public static final String FRAGMENT_OPUS = "FRAGMENT_OPUS";
	public static final String FRAGMENT_CONTECT = "FRAGMENT_CONTECT";
	
	private FragmentControl(Context context) {
		mContext = context;
	}
	
	public static synchronized FragmentControl getInstance(Context context) {
		if (instance == null){
			instance  = new FragmentControl(context);
		}
		return instance;
	} 
 
	public Fragment getExperienceFragment(){ 
		ExperienceFragment fragment = (ExperienceFragment)mFragmentMaps.get(FRAGMENT_EXPERIENCE); 
		if (fragment == null){
			fragment = new ExperienceFragment();
			mFragmentMaps.put(FRAGMENT_EXPERIENCE, fragment);
		} 
		return fragment;
	}
	
	public Fragment getAbilityFragment(){ 
		AbilityFragment fragment = (AbilityFragment)mFragmentMaps.get(FRAGMENT_ABILITY); 
		if (fragment == null){
			fragment = new AbilityFragment();
			mFragmentMaps.put(FRAGMENT_ABILITY, fragment);
		} 
		return fragment;
	}
	
	public Fragment getOpusFragment(){ 
		OpusFragment fragment = (OpusFragment)mFragmentMaps.get(FRAGMENT_OPUS); 
		if (fragment == null){
			fragment = new OpusFragment();
			mFragmentMaps.put(FRAGMENT_OPUS, fragment);
		} 
		return fragment;
	}
	
	public Fragment getContectFragment(){ 
		ContectFragment fragment = (ContectFragment)mFragmentMaps.get(FRAGMENT_CONTECT); 
		if (fragment == null){
			fragment = new ContectFragment();
			mFragmentMaps.put(FRAGMENT_CONTECT, fragment);
		} 
		return fragment;
	}
 
}
